<?php
namespace app\index\controller;
use think\Controller;
use think\Validate;
use think\Db;
use think\Session;
class Pay extends Sessiond
{  

    public function payxx(){
	$post=input("post.");
	   if($post){
	$post=input("post.");
	
	   }
	
	}
	public function pay()
    {
		$post=input("post.");
     if($post){
		
		 if($post['id']==''){exit(json_encode(array('status'=>'0','msg'=>'请选择充值类型')));}
		 $pay=Db::name('pay')->where('id',$post['id'])->find();

		 if($post['money']=='' or  $post['money']<$pay['money']){
			
			exit(json_encode(array('status'=>'0','msg'=>'金额不能小于'.$pay['money'])));
			 
			 }
			 if($post['money']<0){
			 
			 exit(json_encode(array('status'=>'0','msg'=>'金额不能小于0')));
			 }
		 
		 
		 
		 $user=userarray();$userid=$user['id'];
         if(!$user){exit(json_encode(array('status'=>'0','msg'=>'账户不存在')));}

		 $date['userid']= $userid;
		 $date['paytype']=$pay['id'];
		 $date['money']=$post['money'];
		 $date['number']=$userid."_".time();

		 if(!empty($post['bank']))$date['hksm']=$post['bank'];
		 $date['state']='0';
		  $date['addtime']=date("Y-m-d H:i:s");
 
		 
		 
		  $insert=Db::name('paylist')->insert($date);
		 

		 if($insert)exit(json_encode(array('status'=>'1','msg'=>'操作成功,等待审核！')));
			else exit(json_encode(array('status'=>'0','msg'=>'未知错误')));
	  //exit(json_encode(array('status'=>'0','msg'=>$pay)));
	 }
     
    }
	
	
}
